<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加钱包地址</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <script src="/scripts/miniui/miniui.js"></script>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <style type="text/css">
        html, body {
            font-size: 12px;
            padding: 0;
            margin: 0;
            border: 0;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
<div id="form1" style="padding-top: 20px;text-align:center;">
    <span style="width:80px;display:inline-block;">用户名称：</span>
    <input id="creater" class="mini-buttonedit" onbuttonclick="onButtonEdit" style="width:180px;" name="createrId" textName="createrName" allowInput="false" required="true"/>
    <br/><br/>

    <span style="width:80px;display:inline-block;">钱包地址：</span>
    <input id="address" name="address" class="mini-textbox" style="width:180px;" type="text" required="true" />
    <br/><br/>

    <span style="width:80px;display:inline-block;">币种：</span>
    <input id="tokenType" textName="tokenType" class="mini-combobox" style="width:180px;" data="tokenType" type="text" required="true" />
    <br/><br/>

    <div style="margin: 0 auto;text-align: center">
        <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
        <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
    </div>
</div>
<script type="text/javascript">
  var tokenType = JSON.parse('<%- result %>');
  mini.parse();
  var form = new mini.Form("form1");
  function SaveData() {
    var form = new mini.Form("#form1");
    form.validate();
    var data = form.getData();      //获取表单多个控件的数据
    if (form.validate() == true){
      $.ajax({
        url:"/getdata/walletAddressAdd",
        type:'POST',
        data:{
          userOId:data.createrId,
          address:data.address,
          tokenType:data.tokenType
        },
        success:function (result) {
          if (result){
            alert('钱包地址添加成功！')
            CloseWindow("save");
          }
          else {
            alert('钱包地址添加失败！')
          }
        }
      });
    } else {
      alert('请确认表单数据是否填写完整！')
    }

  }

  ////////////////////
  //标准方法接口定义
  function SetData(data) {
  }

  function GetData() {
    var o = form.getData();
    return o;
  }

  function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
      if (confirm("数据被修改了，是否先保存？")) {
        return false;
      }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
  }
  function onButtonEdit(e) {
    var btnEdit = mini.get('creater');
    mini.open({
      url: "/tribeRoute/tribeMGEditSelectCreater",
      title: "选择用户", width: 600, height: 400,
      ondestroy: function (action) {
        //if (action == "close") return false;
        if (action == "ok") {
          var iframe = this.getIFrameEl();
          var data = iframe.contentWindow.GetData();
          data = mini.clone(data);    //必须
//          console.log(data)
          if (data) {
            btnEdit.setText(data.nickName);
            btnEdit.setValue(data.objectId);
          }
        }
      }
    });

  }

  function onOk(e) {
    SaveData();
  }

  function onCancel(e) {
    CloseWindow("cancel");
  }

</script>
</body>
</html>
